package com.xiaofu.sort.selection;

import com.xiaofu.sort.Sort;

/**
 * @author: xiaofu
 * @DESCRIPTION: a technology seeker
 * @date: 2021-08-02 0:28
 */
public class SelectionSort extends Sort {
    @Override
    protected void sort() {
        for (int end = array.length - 1; end > 0; end--) {
            int maxIndex = 0;
            for (int begin = 1; begin <= end; begin++) {
//                if (array[begin] >= array[maxIndex]){
                if (cmp(maxIndex,begin) <= 0){
                    maxIndex = begin;
                }
            }
            swap(maxIndex, end);
        }
    }
}
